home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Blitz2 / BlitzFaq / FaqLists / DualplayfieldAGA.txt < prev    next >
Encoding:
Text File  |  1996-09-02  |  4.4 KB  |  167 lines

  1. ;
  2. ; Dual playfield display example for AGA Amigas only.
  3. ;
  4. ; Demonstrates how to get the correct colours for the rear
  5. ; playfield by using DisplayControls - see Page 137 of the new
  6. ; manual or press RightAmiga/Help on the same line as the command ;)
  7. ;
  8. ; Ted Bailey 12/2/96
  9. ;
  10.  
  11. NoCli
  12.  
  13. ;SetErr:End:End SetErr
  14.  
  15.  
  16. SpriteMode 2        ; AGA only sprites (64 pixels wide)
  17.  
  18. NEWTYPE.spr         ; for the list of three AGA sprites
  19.   sx.w              ; x position
  20.   xv.w              ; x velocity
  21.   sy.w              ; y    "
  22.   yv.w              ; y    "
  23.   ch.w              ; sprite channel to display sprite through
  24. End NEWTYPE         ;
  25.  
  26. Dim List sprites.spr(2)
  27.  
  28.  
  29. BitMap 0,384,288,4  ; front playfield 16 colour bitmap
  30. BitMap 1,384,288,4  ; back playfield 16 colour bitmap
  31.  
  32. InitShape 0,64,64,4 ; shape to turn into a sprite
  33. ShapesBitMap 0,2    ; for drawing directly onto shapes 'bitmap'
  34.  
  35. InitPalette 0,256   ; colour regs 0 and 16 are transparent
  36.                     ; colour regs 1->15 are for front playfield
  37.                     ; colour regs 15->31 are for back playfield
  38.                     ; colour regs 240->255 are for sprites
  39.  
  40.                     ; AGA dualplayfield, smoothscrolling display
  41. InitCopList 0,40,256,$10038,8,256,0
  42.  
  43.  
  44.             ; make the back playfield use colour registers 16->31
  45.             ; by putting %0001110000000000 ($1c00) into BPLCON3
  46.             ; and make the sprites use colour registers 240->255
  47.             ; by putting %0000000011101110 ($00ee) into BPLCON4
  48. DisplayControls 0,0,$1c00,$00ee
  49.  
  50.  
  51. VWait 50:BLITZ
  52.  
  53. Gosub initcolours
  54. Gosub initbitmaps
  55. Gosub initsprites
  56.  
  57. d.w=0       ; initialise 'degrees' counter
  58. fx.q=16     ; front playfield x starting position
  59. fy.q=16     ;   "       "     y    "        "
  60. bx.q=16     ; back      "     x    "        "
  61. by.q=16     ;   "       "     y    "        "
  62.  
  63.  
  64. CreateDisplay 0:DisplayPalette 0,0
  65.  
  66. Repeat
  67.   VWait
  68.   DisplayBitMap 0,0,fx,fy,1,bx,by
  69.  
  70.   Gosub movesprites     ; move/display 3 64*64 16 colour sprites
  71.  
  72.   ang.f=d*Pi/180        ;
  73.   sinn=Sin(ang)*16      ; move front and back playfields
  74.   coss=Cos(ang)*16      ; in a circle pattern
  75.                         ;
  76.   fx=16+sinn            ;
  77.   fy=16+coss            ;
  78.                         ;
  79.   bx=16+coss            ;
  80.   by=16+sinn            ;
  81.  
  82.   d+3:If d>359 Then d=0 ; increment degrees counter
  83.  
  84. Until Joyb(0)
  85.  
  86. End
  87.  
  88.  
  89. .initcolours
  90.   ;
  91.   For cr=1 To 15                       ;
  92.     AGAPalRGB 0,cr,0,Rnd(255),50+cr*10 ; front playfield colours
  93.   Next                                 ;
  94.   ;
  95.   For cr=17 To 31                      ;
  96.     AGAPalRGB 0,cr,50+cr*5,Rnd(255),0  ; back playfield colours
  97.   Next                                 ;
  98.   ;
  99.   For cr=240 To 255                    ;
  100.     col=(255-cr)*15                    ;
  101.     AGAPalRGB 0,cr,col,col,col         ; sprite colours
  102.   Next                                 ;
  103.   ;
  104. Return
  105.  
  106.  
  107. .initbitmaps
  108.   ;
  109.   Use BitMap 0            ; draw some random lines + circles on
  110.   For i.w=1 To 15         ; the front bitmap
  111.     For n.w=1 To 5
  112.       Line Rnd(384),Rnd(288),Rnd(384),Rnd(288),i
  113.       Circlef Rnd(384),Rnd(288),10+Rnd(10),10+Rnd(10),i
  114.     Next
  115.   Next
  116.   ;
  117.   Use BitMap 1            ; draw some random circles on the back
  118.   For i=1 To 15           ; bitmap
  119.     For n=1 To 5
  120.       Circlef Rnd(384),Rnd(288),20+Rnd(10),20+Rnd(10),i
  121.     Next
  122.   Next
  123.   ;
  124. Return
  125.  
  126.  
  127. .initsprites
  128.   ;
  129.   Use BitMap 2        ; draw some concentric circles on the
  130.   For i=1 To 15       ; shapes' bitmap
  131.     Circlef 32-i/2,32-i/2,32-i*2,16-i
  132.   Next
  133.   GetaSprite 0,0      ; turn the shape into a sprite
  134.   Free Shape 0        ; get rid of shape
  135.   ;
  136.   chn.w=0             ; initialise sprite channel counter
  137.   USEPATH sprites()
  138.   While AddItem(sprites())
  139.     \sx=50+Rnd(100)   ;
  140.     \xv=1+Rnd(4)      ; initialise each sprites' x/y positions
  141.     \sy=-50-Rnd(50)   ; and velocities.
  142.     \yv=1             ;
  143.     \ch=chn           ; set the sprite channel to display through
  144.     chn+2             ; needs 2 channels per sprite (16 colours)
  145.   Wend
  146.   ;
  147. Return
  148.  
  149.  
  150. .movesprites
  151.   ;
  152.   USEPATH sprites()
  153.   ResetList sprites()
  154.   While NextItem(sprites())
  155.     \sx+\xv                                 ;
  156.     If \sx<0 Then \xv=-\xv:\sx=0            ; bounce off walls
  157.     If \sx>256 Then \xv=-\xv:\sx=256        ;
  158.     ;
  159.     \yv+1                                   ;
  160.     \sy+\yv                                 ; bounce off ground
  161.     If \sy>194 Then \yv=-10-Rnd(10):\sy=194 ;
  162.     ;
  163.     DisplaySprite 0,0,\sx,\sy,\ch           ; show the sprite
  164.   Wend
  165.   ;
  166. Return
  167.